<template>
    <div>
      <h2>进度管理</h2>
    <el-table :data="progressList" style="width: 100%">
      <el-table-column prop="stage" label="阶段" width="150" />
      <el-table-column prop="status" label="状态" width="100">
        <template #default="scope">
          <el-tag :type="scope.row.status === '已完成' ? 'success' : 'info'">
            {{ scope.row.status }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="deadline" label="截止时间" width="180" />
      <el-table-column prop="finishTime" label="完成时间" width="180" />
      <el-table-column label="操作" width="120">
        <template #default="scope">
          <el-button
            v-if="scope.row.status !== '已完成'"
            size="mini"
            type="primary"
            @click="uploadFile(scope.$index)"
          >上传</el-button>
          <el-button
            v-if="scope.row.file"
            size="mini"
            @click="downloadFile(scope.row.file)"
          >下载</el-button>
        </template>
      </el-table-column>
    </el-table>
    </div>
  </template>

<script setup>
import { ref } from 'vue'
import { ElMessage } from 'element-plus'

const progressList = ref([
  {
    stage: '选题',
    status: '已完成',
    deadline: '2024-03-01',
    finishTime: '2024-02-28',
    file: 'topic.pdf'
  },
  {
    stage: '开题报告',
    status: '未完成',
    deadline: '2024-04-01',
    finishTime: '',
    file: ''
  },
  {
    stage: '论文初稿',
    status: '未完成',
    deadline: '2024-05-01',
    finishTime: '',
    file: ''
  },
  // 可继续添加
])

function uploadFile(index) {
  // TODO: 调用el-upload或后端接口实现上传
  ElMessage.info('上传功能待实现，当前阶段索引：' + index)
}

function downloadFile(file) {
  // TODO: 调用后端接口下载
  ElMessage.info('下载文件：' + file)
}
</script>